package vaadin.lab7;

import com.vaadin.data.Item;
import com.vaadin.ui.Component;
import com.vaadin.ui.DefaultFieldFactory;
import com.vaadin.ui.Field;

@SuppressWarnings("serial")
public class ProductFieldFactory extends DefaultFieldFactory {

    public static final String[] PRODUCT_FIELD_ORDER = new String[] { "name",
            "price", "options", "available" };

    @Override
    public Field createField(Item item, Object propertyId, Component uiContext) {
        Field field = vaadin.lab6.Lab.createFieldByProperty(propertyId,
                item.getItemProperty(propertyId));
        if (field == null) {
            return super.createField(item, propertyId, uiContext);
        }
        return field;
    }
}